import Rx from "rxjs"

let foo = Rx.Observable.create(observer=>{
    console.log("hello");
    observer.next(42);//表示返回了一个值，每次返回值都会调用subscrible中的函数，回调结束后继续
    console.log("finish");
    observer.complete("over");
    console.log("console.log after over");//虽然已经结束了，但是里面的运行不会结束
    observer.next("after over");//在complete后的就不会再继续执行了
});


//这里的感觉有点类似于foo(fn)的感觉，将回调传给观察者
foo.subscribe(x=>console.log(x));
foo.subscribe(x=>console.log(x));


var clicks = Rx.Observable.fromEvent(document, 'click');
clicks.subscribe(x => console.log("one="+x));
clicks.subscribe(x => console.log("two="+x));
